﻿@model IEnumerable<IPublishedEntityObject>
@{
    bool? isPublished = ViewBag.IsPublished;
    string pageUrlFilter = ViewBag.PageUrlFilter;
    ResFile = "cms_Pages";
    var viewModel = new[] 
    { 
        new CmsItemSwitcherModel{ IsSelected = isPublished == null, Title = _("Total"), Count = ViewBag.AllCount , Url = "?isPublished=null", Value = "null"},
        new CmsItemSwitcherModel{ IsSelected = isPublished == true, Title = _("Published"), Count = ViewBag.PublishedCount, Url = "?isPublished=true", Value = "true"},
        new CmsItemSwitcherModel{ IsSelected = isPublished == false, Title = _("Unpublished"), Count = ViewBag.DraftCount, Url = "?isPublished=false", Value ="false" }
    };
}


@using (Html.BeginForm("index", "cmspage", FormMethod.Get, new { id = "pageFilter", @class = "b-form" }))
{

    if (ViewBag.AllCount > 0)
    {

    <nav role="navigation">
        <ul class="b-sub-nav b-sub-nav_inner g-clear">
            <li class="b-sup-nav__item b-sup-nav__item_first"><b>@_("Stats:")</b></li>
            @foreach (var item in viewModel)
            {
                if (item.Count > 0)
                {
                    if (item.IsSelected)
                    {
                        <li class="b-sup-nav__item b-sup-nav__item_current">@item.Title (@item.Count)</li>
                    }
                    else
                    { 
                        <li class="b-sup-nav__item js-page-filter">@item.Title (@item.Count)</li>
                    }
                }
            }
        </ul>
    </nav>
    }
 
    <div style="float: right">
        @Html.TextBox("PageUrlFilter", pageUrlFilter, new { @class = "text", placeholder = _("Page URL filter") })
        @Html.Hidden("IsPublished", isPublished)
        <input type="submit" class="b-button b-button_small b-button_colour_grey" title="@_("Apply")" value="@_("Apply")" />
    </div>
}
